using System.Collections;
using System.Collections.Generic;
using Sirenix.OdinInspector;
using UnityEngine;

namespace TMPAnimationLib
{
    [CreateAssetMenu(fileName = "TextAnimConfig", menuName = "配置数据/文本动画配置/Create TextAnimConfig", order = 5)]
    public class AnimConfig : SerializedScriptableObject, IAnimConfig
    {
        //------------------------------ Schedule ------------------------------//
        [Title("单个字符的动画时间")] 
        public float SingleCharAnimTime;
        [Title("文本动画类型"), ValueDropdown("TextAnimTypes")]
        public TextAnimType AnimType;
        [Title("总动画时间"), ShowIf("@this.AnimType == TextAnimType.FixedTotalTime")]
        public float TotalTime;
        [Title("字符动画开始的间隔时间"), ShowIf("@this.AnimType == TextAnimType.FixedInterval")]
        public float IntervalTime;
        
        [Title("是否在播放字符动画开始前隐藏字符")]
        public bool IsHideCharBeforeAnimBegin;
        [Title("是否在单个字符动画结束后隐藏字符")]
        public bool IsHideCharAfterAnimEnd;
        [Title("是否在全部字符动画结束后隐藏字符")]
        public bool IsHideCharAfterAllAnimEnd;
        
        [Title("是否跳过空字符的动画")]
        public bool IsJumpEmptyCharAnim;
        
        //------------------------------ Move ------------------------------//
        [Title("是否开启位移动画")] 
        public bool EnableMoveAnim;
        [Title("位移动画初始位置的偏移量"), ShowIf("@this.EnableMoveAnim == true")]
        public Vector3 BeginPosOffset;
        [Title("位移动画结束位置的偏移量"), ShowIf("@this.EnableMoveAnim == true")]
        public Vector3 EndPosOffset;
        [Title("是否开启位移动画初始位置的随机偏移"), ShowIf("@this.EnableMoveAnim == true && this.EnableSequenceBeginPosOffset == false")] 
        public bool EnableRandomBeginPosOffset;
        [Title("位移动画初始位置随机偏移的随机系数区间"), ShowIf("@this.EnableMoveAnim == true && this.EnableRandomBeginPosOffset == true")]
        public Vector2 BeginPosOffset_RandomRange;
        [Title("是否开启位移动画初始位置的序列偏移"), ShowIf("@this.EnableMoveAnim == true && this.EnableRandomBeginPosOffset == false")] 
        public bool EnableSequenceBeginPosOffset;
        [Title("位移动画初始位置的序列偏移乘数"), ShowIf("@this.EnableMoveAnim == true && this.EnableSequenceBeginPosOffset == true")] 
        public float SequenceBeginPosOffsetRatioMultiplier;
        [Title("位移动画初始位置的序列偏移曲线"), ShowIf("@this.EnableMoveAnim == true && this.EnableSequenceBeginPosOffset == true")] 
        public AnimationCurve SequenceBeginPosOffsetRatioCurve;
        [Title("位移动画曲线"), ShowIf("@this.EnableMoveAnim == true")]
        public AnimationCurve MoveAnimCurve;
        //------------------------------ Rotate ------------------------------//
        [Title("是否开启旋转动画")] 
        public bool EnableRotateAnim;
        [Title("旋转动画初始旋转角度"), ShowIf("@this.EnableRotateAnim == true")]
        public Vector3 BeginRotate;
        [Title("旋转动画结束旋转角度"), ShowIf("@this.EnableRotateAnim == true")]
        public Vector3 EndRotate;
        [Title("是否开启旋转动画初始旋转角度的随机偏移"), ShowIf("@this.EnableRotateAnim == true && this.EnableSequenceBeginRotate == false")]
        public bool EnableRandomBeginRotate;
        [Title("旋转动画初始旋转角度的随机系数区间"), ShowIf("@this.EnableRotateAnim == true && this.EnableRandomBeginRotate == true")]
        public Vector2 BeginRotate_RandomRange;
        [Title("是否开启旋转动画初始旋转角度的序列偏移"), ShowIf("@this.EnableRotateAnim == true && this.EnableRandomBeginRotate == false")] 
        public bool EnableSequenceBeginRotate;
        [Title("旋转动画初始旋转角度的序列偏移乘数"), ShowIf("@this.EnableRotateAnim == true && this.EnableSequenceBeginRotate == true")] 
        public float SequenceBeginRotateRatioMultiplier;
        [Title("旋转动画初始旋转角度的序列偏移曲线"), ShowIf("@this.EnableRotateAnim == true && this.EnableSequenceBeginRotate == true")] 
        public AnimationCurve SequenceBeginRotateRatioCurve;
        [Title("旋转动画曲线"), ShowIf("@this.EnableRotateAnim == true")]
        public AnimationCurve RotateAnimCurve;
        //------------------------------ Scale ------------------------------//
        [Title("是否开启缩放动画")] 
        public bool EnableScaleAnim;
        [Title("缩放动画初始缩放比例"), ShowIf("@this.EnableScaleAnim == true")]
        public Vector3 BeginScale;
        [Title("缩放动画结束缩放比例"), ShowIf("@this.EnableScaleAnim == true")]
        public Vector3 EndScale;
        [Title("是否开启缩放动画初始缩放的随机偏移"), ShowIf("@this.EnableScaleAnim == true && this.EnableSequenceBeginScale == false")]
        public bool EnableRandomBeginScale;
        [Title("缩放动画初始缩放比例的随机系数区间"), ShowIf("@this.EnableScaleAnim == true && this.EnableRandomBeginScale == true")]
        public Vector2 BeginScale_RandomRange;
        [Title("是否开启缩放动画初始缩放比例的序列偏移"), ShowIf("@this.EnableScaleAnim == true && this.EnableRandomBeginScale == false")] 
        public bool EnableSequenceBeginScale;
        [Title("缩放动画初始缩放比例的序列偏移乘数"), ShowIf("@this.EnableScaleAnim == true && this.EnableSequenceBeginScale == true")] 
        public float SequenceBeginScaleRatioMultiplier;
        [Title("缩放动画初始缩放比例的序列偏移曲线"), ShowIf("@this.EnableScaleAnim == true && this.EnableSequenceBeginScale == true")] 
        public AnimationCurve SequenceBeginScaleRatioCurve;
        [Title("缩放动画曲线"), ShowIf("@this.EnableScaleAnim == true")]
        public AnimationCurve ScaleAnimCurve;
        //------------------------------ Color ------------------------------//
        [Title("是否开启颜色渐变动画")] 
        public bool EnableColorAnim;
        [Title("颜色渐变"), ShowIf("@this.EnableColorAnim == true")]
        public Gradient gradient;
        //------------------------------ Camber ------------------------------//
        [Title("是否开启弧形排列")] 
        public bool EnableCamber;
        [Title("弧形排列角度值"), ShowIf("@this.EnableCamber == true")] 
        public float CamberAngle;
        
        
        public enum TextAnimType
        {
            FixedTotalTime,
            FixedInterval,
        }
        static IEnumerable TextAnimTypes = new ValueDropdownList<TextAnimType>()
        {
            {"固定总动画时间", TextAnimType.FixedTotalTime},
            {"固定字符动画间隔时间", TextAnimType.FixedInterval},
        };
    }
}